<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="t" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<s:url var="search_url" value="/organizacoes/index"/>
<div class="row-fluid">

    <form class="form-search" method="POST" action="${search_url}">
        <input type="text" name="search" class="input-xxlarge search-query" />
        <button class="btn btn-info btn-small">
            Buscar
            <i class="icon-search icon-on-right bigger-110"></i>
        </button>
    </form>
    <table class="table table-bordered table-striped table-hover">
        <thead>
            <tr>
                <th><i class="icon-caret-right blue"></i>Sigla</th>
                <th><i class="icon-caret-right blue"></i>Nome</th>
                <th><i class="icon-caret-right blue"></i>Tipo</th>
                <th><i class="icon-caret-right blue"></i>Órgão Superior</th>

                <th width="80"></th>
            </tr>
        </thead>

        <tbody>
            <c:forEach var="organizacao" items="${organizacoes}">
                <s:url value="/organizacoes/edit" var="edit_url">
                    <s:param name="organizacaoId" value="${organizacao.id}" />
                </s:url>
                <s:url value="/organizacoes/remove" var="remove_url">
                    <s:param name="organizacaoId" value="${organizacao.id}" />
                </s:url>
                <s:url value="/organizacoes/detail" var="detail_url">
                    <s:param name="organizacaoId" value="${organizacao.id}" />
                </s:url>
                <tr>
                    <td><a href="#">${organizacao.sigla}</a></td>
                    <td>
                        <a href="#">${organizacao.nome}</a>

                    </td>
                    <td>
                        <c:if test="${organizacao.getClass().name =='com.tomasio.projects.trainning.dto.ComandoDTO'}">
                            <span class="badge badge-info">ODSA</span>
                        </c:if>
                        <c:if test="${organizacao.getClass().name =='com.tomasio.projects.trainning.dto.UnidadeDTO'}">
                            <span class="badge badge-warning">Unidade</span>
                        </c:if>
                        <c:if test="${organizacao.getClass().name =='com.tomasio.projects.trainning.dto.ExternoDTO'}">
                            <span class="badge badge-success">Externa</span>
                        </c:if>

                    </td>
                    <td>

                        <c:if test="${organizacao.getClass().name =='com.tomasio.projects.trainning.dto.UnidadeDTO'}">
                            ${organizacao.parent.sigla}
                        </c:if>

                    </td>
                    <td>
                        <div class="btn-group">
                            <button data-toggle="dropdown" class="btn btn-small btn-info dropdown-toggle">
                                Ações
                                <span class="caret"></span>
                            </button>

                            <ul class="dropdown-menu dropdown-default pull-right">
                                <li>    
                                    <a href="${edit_url}">Editar</a>
                                </li>

                                <li>    
                                    <a href="${remove_url}" class="remove">Excluir</a>
                                </li>

                            </ul>
                        </div>
                    </td>
                </tr>
            </c:forEach>
            <tr class="info">
                <td colspan="5"><b>Total: </b> ${total}</td>
            </tr> 
        </tbody>
    </table>
</div>
<div>


    <a href="<s:url value="/organizacoes/new"/>" class="btn btn-info"><i class="icon-plus-sign"></i> Nova Organização</a>
</div>


<!-- inline scripts related to this page -->

<script type="text/javascript">

</script>